package com.example.demofdfs.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.example.demofdfs.aop.TestLogAnnotation;
import com.example.demofdfs.mapper.UserMapper;
import com.example.demofdfs.model.User;
import com.example.demofdfs.service.UserService;

@Service
@Transactional(readOnly = true)
public class UserServiceImpl implements UserService {

	@Autowired
	private UserMapper userMapper;
	
	@Transactional(readOnly = false)
	@Override
	@TestLogAnnotation()
	public int addUser(User user) {
		
		user.updateInfo();
		return userMapper.addUser(user);
	}

	@Override
	@TestLogAnnotation()
	public User getUser(int id) {
		return userMapper.getUser(id);
	}

	@Override
	@Transactional(readOnly = false)
	public int updateUser(User user) {
		user.updateInfo();
		return userMapper.update(user);
	}

}
